package lanqiao;

import java.util.Scanner;

public class 数字三角形 {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        int[][] arr = new int[N][N];
        int[][] dp = new int[N][N];
        for (int i = 0; i < N; i++) {
            for (int j = 0; j <= i; j++) {
                arr[i][j] = scan.nextInt();
            }
        }
        dp[0][0] = arr[0][0];
        int cur = 1;
        while (cur != N){
            for (int i = 0; i <=cur; i++) {
                if (i==0){
                    dp[cur][i] = dp[cur-1][i]+arr[cur][i];
                }
                if (i>0){
                    dp[cur][i] = Math.max(dp[cur-1][i],dp[cur-1][i-1])+arr[cur][i];
                }

            }
            cur++;
        }
        if ((N ^ 1) != 0){
            System.out.println(dp[N-1][N/2]);
        }else {
            System.out.println(Math.max(dp[N-1][N/2+1],dp[N-1][N/2]));
        }
    }

    }

//    public static int process(int[][] arr,int left,int right,int n,int m,int ans){
//        if (arr.length-1==n){
//            return ans+arr[n][m];
//        }
//        int p1=0;
//        int p2=0;
//
//        if (left>arr.length/2){
//             p2=process(arr,left,right+1,n+1,m+1,ans+arr[n][m]);
//        }else if (right>arr.length/2){
//              p1=process(arr,left+1,right,n+1,m,ans+arr[n][m]);
//        }else {
//             p1 = process(arr, left + 1, right, n + 1, m, ans + arr[n][m]);
//             p2 = process(arr, left, right + 1, n + 1, m + 1, ans + arr[n][m]);
//        }
//            ans = Math.max(p1, p2);
//        return ans;
//    }
//}
